<template>
    <div>
        <h1>医生管理</h1>
 <table class="table table-bordered" style="background-color:cornflowerblue;">
            <tbody>
                <tr>
                    <td>医生姓名</td>
                    <td>医生头像</td>
                    <td>所属科室</td>
                    <td>第一执业医院</td>
                    <td>创建日期</td>
                </tr>
                <tr v-for="value in infoo.list"> 
                    <td>{{value.name}}</td>
                    <td><img :src="value.img" width="60px" height="60px"></td>
                    <td>{{value.oname}}</td>
                    <td>{{value.onehospital}}</td>
                    <td>{{value.createTimes.substr(0,10)}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <div>
        <span>总条数:{{infoo.totalnum}}</span>
        <span>总页数:{{infoo.totalpage}}</span>
        <span>当前页:{{info.pageindex}}/{{infoo.totalpage}}</span>
        <input type="button" value="首页" @click="fn(1)">
        <input type="button" value="上一页" @click="fn(info.pageindex-1)">
        <input type="button" v-for="o in infoo.totalpage" :value="o" @click="fn(o)">
        <input type="button" value="下一页" @click="fn(info.pageindex+1)">
        <input type="button" value="尾页" @click="fn(infoo.totalpage)">
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios';
import { onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';

let info:any=ref({
       pageindex:1,
       pagesize:3
})

let infoo:any=ref({
    list:[],
    totalnum:"",
    totalpage:""
})

const fn=(num:any)=>{
    if(num<1){
        info.value.pageindex=1;
        return;
    }
    if(num>infoo.value.totalpage){
        info.value.pageindex=infoo.value.totalpage
        return;
    }
    info.value.pageindex=num;
    GetList()
}

onMounted(()=>{
    GetList();
})

const GetList=()=>{
    axios({
        url:'https://localhost:7118/api/Hospital/GetHospital',
        method:'get',
        params:info.value
    })
    .then((res)=>{
        console.log(res);
        infoo.value=res.data
    })
    .catch((err)=>{
        console.log(err);
    })
}
</script>

<style scoped>

</style>